# 从Django导入创建表单需要的模块
from django import forms 
# 导入Comment数据模型类
from .models import Comment 

# 继承表单类创建邮箱文章表单
class EmailPostForm(forms.Form): 
    name = forms.CharField(max_length=25) 
    email = forms.EmailField() 
    to = forms.EmailField() 
    comments = forms.CharField(required=False, widget=forms.Textarea) 
# 创建评论表单类，该类继承自Django forms的ModelForm类，可以自动根据配置生成表单
class CommentForm(forms.ModelForm): 
    class Meta: 
# 声明此表单是基于Comment数据模型类生成的 
        model = Comment 
# 生成此表单有三个字段，分别是name，email，body 
        fields = ('name', 'email', 'body') 

class SearchForm(forms.Form): 
    query = forms.CharField() # 此表单只有一个搜索内容字段